<?php
class ProfessorServico {
	private $profDao;
	
	public function __construct() {
		$this->profDao = new ProfessorDAO();
	}
	
	public function getProfDao() {
		return $this->profDao;
	}
	
	public function setProfDao($profDao) {
		$this->profDao = $profDao;
	}
	
	public function cadastrarProfessor($vetor) {
		$prof = new Professor(); 
		$obj = $prof->construct($vetor);
		
		if (!$this->profDao->contem($obj)) {
			$this->profDao->inserir($obj);
			return 0;
		}
		else
			return 1;
	}
	
	public function atualizarProfessor($vetor) {
		$obj = new Professor();
		$obj = Professor::construct($vetor);
		$this->profDao->atualizar($obj);
	}
	
	public function listarProfessor() {
		$res = $this->profDao->buscarTodos();
		
		return $res;
	}
	
	public function removerProfessor($vetor) {
		$id = $vetor['id'];
		$this->profDao->apagar($id);
	}
	
	public function buscar() {
		
	}
	
	public function buscarElemento($vetor) {
		$buscado = new Professor();
		
		if (isset($vetor['id']))
			$buscado->setId($vetor['id']);
		if (isset($vetor['matricula']))
			$buscado->setMatricula($vetor['matricula']);
		
		$profBuscado = $this->profDao->buscar($buscado);
		return $profBuscado;
	}
	
	public function buscarPorColegiado($colegiado) {
		$res = $this->profDao->buscarTodosSerach($colegiado);

		return $res;
	}
}
?>